package com.ruoyi.config.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.config.domain.ZfbpayConfig;
import com.ruoyi.config.service.IZfbpayConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付宝支付配置Controller
 *
 * @author ruoyi
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/zfbpayConfig/zfbpayConfig")
public class ZfbpayConfigController extends BaseController {
    @Autowired
    private IZfbpayConfigService zfbpayConfigService;

    /**
     * 查询支付宝支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZfbpayConfig zfbpayConfig) {
        startPage();
        List<ZfbpayConfig> list = zfbpayConfigService.selectZfbpayConfigList(zfbpayConfig);
        return getDataTable(list);
    }

    /**
     * 导出支付宝支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:export')")
    @Log(title = "支付宝支付配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZfbpayConfig zfbpayConfig) {
        List<ZfbpayConfig> list = zfbpayConfigService.selectZfbpayConfigList(zfbpayConfig);
        ExcelUtil<ZfbpayConfig> util = new ExcelUtil<ZfbpayConfig>(ZfbpayConfig.class);
        util.exportExcel(response, list, "支付宝支付配置数据");
    }

    /**
     * 获取支付宝支付配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(zfbpayConfigService.selectZfbpayConfigById(id));
    }

    /**
     * 新增支付宝支付配置
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:add')")
    @Log(title = "支付宝支付配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZfbpayConfig zfbpayConfig) {
        return toAjax(zfbpayConfigService.insertZfbpayConfig(zfbpayConfig));
    }

    /**
     * 修改支付宝支付配置
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:edit')")
    @Log(title = "支付宝支付配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZfbpayConfig zfbpayConfig) {
        return toAjax(zfbpayConfigService.updateZfbpayConfig(zfbpayConfig));
    }

    /**
     * 删除支付宝支付配置
     */
    @PreAuthorize("@ss.hasPermi('zfbpayConfig:zfbpayConfig:remove')")
    @Log(title = "支付宝支付配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zfbpayConfigService.deleteZfbpayConfigByIds(ids));
    }
}
